<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<%@include file="/WEB-INF/include-head.jsp"%>

<link rel="stylesheet" href="css/pagination.css" />
<script type="text/javascript" src="jquery/jquery.pagination.js"></script>
<script type="text/javascript" src="crowd/my-order.js"></script>
<%@ include file="/WEB-INF/modal-order-look.jsp"%>
</head>
<script type="text/javascript">

	$(function(){
		
		// 1.为分页操作准备初始化数据
		window.pageNum = 1;
		window.pageSize = 5;
		window.keyword = "";
		
		// 2.调用执行分页的函数，显示分页效果
		generatePage();
		
		// 3.给查询按钮绑定单击响应函数
		$("#searchBtn").click(function(){
			
			// ①获取关键词数据赋值给对应的全局变量
			window.keyword = $("#keywordInput").val();
			
			// ②调用分页函数刷新页面
			generatePage();
			
		});
		
		//查看项目详情
		$("#orderPageBody").on("click",".checkBtn",function(){

			$("#orderLookModal").modal("show");
			
			var ajaxResult = $.ajax({
				
				"url":"order/look.json",
				"data": {"orderId":this.id},
				"type": "post",
				"dataType":"json",
				"async":false
			});

			// 判断当前响应状态码是否为200
			var statusCode = ajaxResult.status;
			
			// 如果当前响应状态码不是200，说明发生了错误或其他意外情况，显示提示消息，让当前函数停止执行
			if(statusCode != 200) {
				layer.msg("失败！响应状态码="+statusCode+" 说明信息="+ajaxResult.statusText);
				return null;
			}
			
			// 如果响应状态码是200，说明请求处理成功
			var resultEntity = ajaxResult.responseJSON;
			
			// 从resultEntity中获取result属性
			var result = resultEntity.result;
			
			// 判断result是否成功
			if(result == "FAILED") {
				layer.msg(resultEntity.message);
				return null;
			}
			
			//获取项目
			var order = resultEntity.data;
			
			//获取属性值
			var orderId = order.id;
			var orderNum = order.orderNum;
			var orderAmount = order.orderAmount;
			var orderRemark = order.orderRemark;
			var projectName = order.projectName;
			var returnCount = order.returnCount;
			var returntContent = order.returntContent;
			var supportPrice = order.supportPrice;
			var receiveName = order.receiveName;
			var phoneNum = order.phoneNum;
			var address = order.address;
			
			$("#orderLookModal [name='orderNum']").val(orderNum);
			$("#orderLookModal [name='orderAmount']").val(orderAmount);
			$("#orderLookModal [name='orderRemark']").val(orderRemark);
			$("#orderLookModal [name='projectName']").val(projectName);
			$("#orderLookModal [name='returnCount']").val(returnCount);
			$("#orderLookModal [name='returntContent']").val(returntContent);
			$("#orderLookModal [name='supportPrice']").val(supportPrice);
			$("#orderLookModal [name='receiveName']").val(receiveName);
			$("#orderLookModal [name='phoneNum']").val(phoneNum);
			$("#orderLookModal [name='address']").val(address);
		});
		$("#lookModal").modal("hide") 
		
	});
	
</script>
<body>
	<%@ include file="/WEB-INF/include-nav.jsp"%>
	<div class="container-fluid">
		<div class="row">
			<%@ include file="/WEB-INF/include-sidebar.jsp"%>
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">
							<i class="glyphicon glyphicon-th"></i> 数据列表
						</h3>
					</div>
					<div class="panel-body">
						<form class="form-inline" role="form" style="float: left;">
							<div class="form-group has-feedback">
								<div class="input-group">
									<div class="input-group-addon">查询条件</div>
									<input id="keywordInput" class="form-control has-success"
										type="text" placeholder="请输入查询条件">
								</div>
							</div>
							<button id="searchBtn" type="button" class="btn btn-warning">
								<i class="glyphicon glyphicon-search"></i> 查询
							</button>
						</form>
						<br>
						<hr style="clear: both;">
						<div class="table-responsive">
							<table class="table  table-bordered">
								<thead>
									<tr>
										<th width="30">#</th>
										<th >订单编号</th>
										<th>订单金额</th>
										<th>订单备注</th>
										<th>项目名称</th>
										<th>回报数量</th>
										<th>回报内容</th>
										<th>支持单价</th>
										<th>收货人姓名</th>
										<th>收货人电话</th>
										<th width="60">收货人地址</th>
										<th width="60">操作</th>
									</tr>
								</thead>
								<tbody id="orderPageBody"></tbody>
								<tfoot>
									<tr>
										<td colspan="6" align="center">
											<div id="Pagination" class="pagination"><!-- 这里显示分页 --></div>
										</td>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

</body>
</html>
